<#import "/macro.ftl" as m>
<@m.page_header title='金融资产' />
<div id="page-content-wrapper">
    <div id="page-title">
        <h3>金融资产</h3>
        <p class="font-red mrg10T">每天零点30分开始计算用户到期回款金额入库</p>
        <div id="breadcrumb-right">
            <div class="float-right">
                <a href="/financialassets/add" class="btn medium primary-bg">
                    <span class="button-content">添加金融资产</span>
                </a>
            </div>
        </div>
    </div>
    <div id="page-content">
    	<form id="form" action="/financialassets" method="get">
    		<div class="form-row">
    			<div class="form-input col-md-8">
    				<input placeholder="填写金融资产名称查询" type="text" name="keyword" value="${keyword}">
    			</div>
    			<div class="form-input col-md-2">
		        	<a href="javascript:;" class="btn large primary-bg radius-all-4" id="search" title="Validate!" onclick="$('#form').trigger('submit');">
			            <span class="button-content">
			                查询
			            </span>
	                </a>
		        </div>
    		</div>
    		<div class="row">
    			<div class="col-md-4">
    				<div class="form-row">
		    			<div class="form-input col-md-5">
		    				<input placeholder="起息日从" type="text" name="valueDateStart" value="<#if valueDateStart??>${valueDateStart?string('yyyy-MM-dd')}</#if>" onclick="WdatePicker({isShowWeek:true,dateFmt:'yyyy-MM-dd'})">
		    			</div>
		    			<div class="form-label col-md-1">
		    				<label>-</label>
		    			</div>
		    			<div class="form-input col-md-5">
				        	<input placeholder="到起息日" type="text" name="valueDateEnd" value="<#if valueDateEnd??>${valueDateEnd?string('yyyy-MM-dd')}</#if>" onclick="WdatePicker({isShowWeek:true,dateFmt:'yyyy-MM-dd'})">
				        </div>
		    		</div>
    			</div>
    			<div class="col-md-4">
    				<div class="form-row">
		    			<div class="form-input col-md-5">
		    				<input placeholder="到期日从" type="text" name="dueDateStart" value="<#if dueDateStart??>${dueDateStart?string('yyyy-MM-dd')}</#if>" onclick="WdatePicker({isShowWeek:true,dateFmt:'yyyy-MM-dd'})">
		    			</div>
		    			<div class="form-label col-md-1">
		    				<label>-</label>
		    			</div>
		    			<div class="form-input col-md-5">
				        	<input placeholder="到到期日" type="text" name="dueDateEnd" value="<#if dueDateEnd??>${dueDateEnd?string('yyyy-MM-dd')}</#if>" onclick="WdatePicker({isShowWeek:true,dateFmt:'yyyy-MM-dd'})">
				        </div>
		    		</div>
    			</div>
    		</div>
    	</form>
    	<table class="table">
	        <thead>
	            <tr>
	                <th>名称</th>
	                <th class="text-center">金额(元)</th>
	                <th class="text-center">库存(元)</th>
	                <th>起息日</th>
	                <th>到期日</th>
	                <th>存续期限</th>
	                <th>停用</th>
	                <th>操作</th>
	            </tr>
	        </thead>
	        <tbody>
	        	<#list financialassets.list as financialasset>
					<tr id="${financialasset.id}">
		                <td>${financialasset.name}</td>
		                <td class="text-right">${financialasset.amount?string(',##0.00')}</td>
		                <td class="text-right">${financialasset.inventory?string(',##0.00')}</td>
		                <td>${financialasset.valueDate?string('yyyy-MM-dd')}</td>
		                <td>${financialasset.dueDate?string('yyyy-MM-dd')}</td>
		                <td>${financialasset.duration}天</td>
		                <td>${financialasset.disable?string("停用", "")}</td>
		                <td>
		                    <div class="dropdown">
                                <a href="javascript:;" title="" class="btn medium bg-blue" data-toggle="dropdown">
                                    <span class="button-content">
                                        <i class="glyph-icon font-size-11 icon-cog"></i>
                                        <i class="glyph-icon font-size-11 icon-chevron-down"></i>
                                    </span>
                                </a>
                                <ul class="dropdown-menu float-right">
				                    <li>
	                                	<a href="/financialassets/${financialasset.id}/products">
					                    	<i class="glyph-icon icon-money mrg5R"></i>
						                    已发售产品
					                    </a>
					                    <a href="/financialassets/${financialasset.id}/inoutstockdetail">
					                    	<i class="glyph-icon icon-align-justify mrg5R"></i>
						                    出入库明细
					                    </a>
				                    </li>
                                    <li>
                                        <a href="/financialassets/${financialasset.id}/edit">
					                    	<i class="glyph-icon icon-edit mrg5R"></i>
					                    	编辑
					                    </a>
                                    </li>
                                    <li>
                                        <a href="javascript:;" onclick="showDelete(${financialasset.id});">
					                    	<i class="glyph-icon icon-remove mrg5R"></i>
                                            删除
					                    </a>
                                    </li>
                                </ul>
                            </div>
		                </td>
		            </tr>
				</#list>    
	    	</tbody>
	    </table>
	    <div class="button-group center-div">
	    	${pagerHelper.content}
	    </div>
    </div>
</div>
<script>

function showDelete( id ){
	$.messager.confirm( "提示", "确定删除金融资产吗？", function(){
		$.post( '/financialassets/' + id + "/delete")
	     .done(function(data){
	     	if(data["status"] == "success"){
	     		$.jGrowl("删除金融资产成功", {sticky:!1,position:"top-right",theme:"bg-green"});
	     		$('.table').find('tr[id=' + id + ']').remove();
	     	}else{
	     		$.jGrowl(data["message"], {sticky:!1,position:"top-right",theme:"bg-red"});
	     	}
	     })
	     .fail(function(){
	     	$.jGrowl("删除金融资产失败", {sticky:!1,position:"top-right",theme:"bg-red"});
	     });
	});
};

</script>